#pragma once
#include "Buffer.h"
#include "PackOut.h"
#include "PackIn.h"
#include <afxsock.h>

class IDataChannelEvent
{
public:
	virtual void	OnReceData(WORD wCmd, PBYTE pBuffer, int nLen) = 0;
	virtual void	OnConnect() = 0;
	virtual void	OnClose(int nErrorCode) = 0;
};

class CDataChannel
	: public CAsyncSocket
{
public:
	CDataChannel();
	~CDataChannel();

public:
	void	SetCallBack(IDataChannelEvent* pCallBack);
	int		SendData(WORD wCmd, PBYTE pBuffer, int nLen);

protected:
	virtual void	OnReceive(int nErrorCode);
	virtual void	OnConnect(int nErrorCode);
	virtual void	OnClose(int nErrorCode);

private:
	CPackOut			m_oBuffer;
	IDataChannelEvent*	m_pCallBack;
	WORD				m_wSeqNum;
};

